package com.sylar.happygps;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.ToggleButton;

public class RoadInfoEditActivity extends Activity implements OnClickListener {

	private TextView tv_road_nav_play_type;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.roadinfoedit);

		Button btn_title_left = (Button) findViewById(R.id.btn_title_left);
		btn_title_left.setVisibility(View.VISIBLE);
		btn_title_left.setText(R.string.app_name);
		btn_title_left.setOnClickListener(this);

		Button btn_help = (Button) findViewById(R.id.btn_help);
		btn_help.setVisibility(View.VISIBLE);
		btn_help.setOnClickListener(this);

		TextView tv_title_name = (TextView) findViewById(R.id.tv_title_name);
		tv_title_name.setVisibility(View.VISIBLE);
		tv_title_name.setText("编辑沿路提示");
		
		
		View layout_road_play_opt = findViewById(R.id.layout_road_play_opt);
		layout_road_play_opt.setOnClickListener(this);
		
		final TextView tv_road_type_lable = (TextView) findViewById(R.id.tv_road_type_lable);
		
		tv_road_nav_play_type = (TextView) findViewById(R.id.tv_road_nav_play_type);
		
		ToggleButton tb_road_switch = (ToggleButton) findViewById(R.id.tb_road_switch);
		
		tb_road_switch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
			
			@Override
			public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
				if(arg1){
					tv_road_type_lable.setText("从道路终点至起点时提示");
				}else{
					tv_road_type_lable.setText("从道路起点至终点时提示");
				}
			}
		});
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.btn_title_left:
			finish();
			break;
		case R.id.btn_help:

			break;
		case R.id.layout_road_play_opt:
			showRoadPlayOpt();
			break;
		default:
			break;
		}
	}
	
	private void showRoadPlayOpt(){
		final String[] items = new String[]{"仅导航时播放","仅导游时播放","导航及导游时均播放"};
		new AlertDialog.Builder(this)
		.setItems(items, new DialogInterface.OnClickListener() {
			
			@Override
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
				if(tv_road_nav_play_type!=null){
					tv_road_nav_play_type.setText(items[which]);
				}
			}
		})
		.setTitle("选择提示类型")
		.create().show();
	}
}
